Skip to content

refactor(aztec-nr): use constructor methods for MessageDelivery variants#23596

Merged
nchamo merged 3 commits into
merge-train/fairiesfrom
nchamo/richer-enums
May 28, 2026
Merged

refactor(aztec-nr): use constructor methods for MessageDelivery variants#23596
nchamo merged 3 commits into
merge-train/fairiesfrom
nchamo/richer-enums

Conversation

@nchamo

@nchamo nchamo commented May 27, 2026

Copy link
Copy Markdown
Contributor

Why

The current MessageDelivery API uses a struct-with-constants pattern (MessageDelivery.OFFCHAIN) that is inflexible: callers can only select from a fixed set of u8 values with no room for additional configuration. For example, a caller might want to set the sender for tags instead of using the transaction default.

Our fix

MessageDelivery is now a proper struct with named constructors (MessageDelivery::offchain(), MessageDelivery::onchain_unconstrained(), MessageDelivery::onchain_constrained()). This pattern is extensible: constructors can accept parameters in the future without changing the callsite shape.

For example, to support a custom sender for tags, the API could be extended to:

MessageDelivery::onchain_unconstrained(SenderForTags::explicit(custom_sender))

All callsites, documentation, and code examples are updated to use the new syntax. A migration note is included.

@nchamo nchamo requested review from a team and nventuro as code owners May 27, 2026 15:58
@nchamo nchamo self-assigned this May 27, 2026
@nchamo nchamo changed the base branch from next to merge-train/fairies May 27, 2026 16:00
…/richer-enums

# Conflicts:
#	docs/docs-developers/docs/resources/migration_notes.md
#	noir-projects/noir-contracts/contracts/test/custom_sync_state_contract/src/main.nr

@vezenovm vezenovm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this refactor a lot. Provides more API flexibility + moves us towards stronger types in aztec-nr and away from primitive types.

@nchamo nchamo merged commit 2d4a609 into merge-train/fairies May 28, 2026
14 checks passed
@nchamo nchamo deleted the nchamo/richer-enums branch May 28, 2026 12:13
danielntmd pushed a commit to danielntmd/aztec-packages that referenced this pull request Jun 4, 2026
BEGIN_COMMIT_OVERRIDE
refactor(aztec-nr): use constructor methods for MessageDelivery variants
(AztecProtocol#23596)
docs: update testing_contracts.md for two-crate aztec new layout
(AztecProtocol#23617)
fix: drop usage of include and indexof on types that support equals
(AztecProtocol#23595)
fix: unused ts expressions in tests (AztecProtocol#23621)
feat(aztec-nr): Get tagging index for constrained delivery  (AztecProtocol#23359)
feat!: demote auth registry to non-protocol contract (AztecProtocol#23106)
feat(aztec-nr)!: embed BoundedVec max length in validation requests
(AztecProtocol#23622)
fix: regenerate standard contract addresses after auth registry demotion
(AztecProtocol#23640)
feat(aztec-nr): encrypt handshake log for indistinguishability (AztecProtocol#23638)
feat!: demote public_checks to non-protocol contract (AztecProtocol#23217)
fix: noir precommit re-staging inside worktrees (AztecProtocol#23628)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants